﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using System.Linq.Expressions;

namespace Web.Admin.test
{
    public partial class [tblName]List :Comm.pageBase
    {
        public BLL.[tblName] bll = new BLL.[tblName]();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
                LoadData();
            }
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            LoadData();
        }


        /// <summary>
        /// 第一次加载页面时候执行
        /// </summary>
        protected void InitPage()
        {
            txtQryguid.Text = Request.QueryString["guid"];
            txtQrytemplateId.Text = Request.QueryString["templateId"];
        }


        /// <summary>
        /// 加载数据
        /// </summary>
        protected void LoadData()
        {
            #region 分页控件绑定

            //翻页参数
            if (inputPageByButton.Value == "0")
            {
                int.TryParse(inputGo2page.Value, out currentPage);
                inputPageByButton.Value = "1";
            }

            //输入参数
            dicCondition.Add("guid", txtQryguid.Text);
            dicCondition.Add("cata", txtQrycata.Text);
            dicCondition.Add("subCata", txtQrysubCata.Text);
            dicCondition.Add("templateId", txtQrytemplateId.Text);
            //排序参数
            dicCondition.Add("orderby", "id asc");

            var pager = bll.List(dicCondition);
            var dtable = pager.dataList;
            thisPagelRecord = pager.totalRecords;
            rpt[tblName]List.DataSource = dtable;
            rpt[tblName]List.DataBind();

            string js2run = thisPagelRecord == 0 ? formatError("对不起，没有符合条件的数据。") : string.Format("<script>pagerInit({0},{1},{2});</script>", currentPage, totalRecord, pageSize);
            ScriptManager.RegisterStartupScript(UpdatePanel[tblName]List, this.GetType(), "bzz", js2run, false); 
            #endregion

        }

    }
}




